package wechat.bean.response.event.menu;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;

import wechat.bean.response.EventMessageBean;

public class MenuPicPhotoAlbumBean extends EventMessageBean {
	private String Count;
	private List<PicListItem> picListItems;
	
	public MenuPicPhotoAlbumBean(String str) throws DocumentException {
		super(str);
	}
	
	public MenuPicPhotoAlbumBean(){
		
	}
	
	public String getCount() {
		return Count;
	}

	public void setCount(String count) {
		Count = count;
	}

	public List<PicListItem> getPicListItems() {
		return picListItems;
	}

	public void setPicListItems(List<PicListItem> picListItems) {
		this.picListItems = picListItems;
	}

	
	
	protected static final String Xpath_Count = "/xml/SendPicsInfo/Count";
	protected static final String Xpath_ScanResult = "/xml/SendPicsInfo/PicList/item";
	
	public void transform() throws Exception {
		super.transform();
		this.setCount(getNodeText(Xpath_Count));
		
		Document doc = super.document;
		List<Node> items = doc.selectNodes(Xpath_ScanResult);
		int itemSize = items.size();
		
		List<PicListItem> picListItems = new ArrayList<PicListItem>();
		for (int i = 0; i < itemSize; i++) {
			Node item = items.get(i);
			
			PicListItem picListItem = new PicListItem();
			picListItem.setPicMd5Sum(item.getStringValue());
			picListItems.add(picListItem);
		}
		setPicListItems(picListItems);
	}


}
